local M = _G.CommonOHOH.class.new(script, script.Parent.base,script.Parent.Name);

--游戏状态,0：等待开始一局游戏，1：正在比赛中，2：结算比赛
function M.new(self)
	return M(self);
end;

function M.ctor(self, parent)
    print("--------init2SeverData---ctor-------->")
	M.super.ctor(self, parent)
    self:init2SeverData()
end;

local HTTP = game:GetService("HttpService")

function M.init2SeverData(self)

    print("--------init2SeverData----------->")
    self.Game:AttributeValueChanged("GameState",function()
        print("GameState----》")

        self.State=self.Game.attribute.GameState
        self.Game.GameStateChangeEvent:Action(self.State)

        if  self.State==2 and #self.ReachPlayers==0 then
            self.Game.TimeOutEvent:Action()
        end
    end)

    self.Game:AttributeValueChanged("StateTime",function()
        print("StateTime----》")
        self.StateTime=self.Game.attribute.StateTime
    
    end)

    self.Game:AttributeValueChanged("ReachPlayers",function()
        print("ReachPlayers----》")
        self.ReachPlayers=HTTP:JSONDecode(self.Game.attribute.ReachPlayers)
        print(self.ReachPlayers)
        if #self.ReachPlayers ~= 0  then
            self.Game.ReachTheEndEvent:Action(self.ReachPlayers)
        end
    end)
end



return M